﻿// Decompiled with JetBrains decompiler
// Type: DnProcessSimulateCommands.StopZero.CApStopZeroCachingValidator
// Assembly: DnProcessSimulateCommands, Version=2402.0.0.890, Culture=neutral, PublicKeyToken=null
// MVID: A885D881-AEDF-447E-852A-6F13102E089C
// Assembly location: C:\Program Files\Tecnomatix_2402\eMPower\DotNetCommands\DnProcessSimulateCommands.dll

using System.Collections.Generic;
using Tecnomatix.Engineering;


namespace DnProcessSimulateCommands.StopZero;

public abstract class CApStopZeroCachingValidator : CApStopZeroBaseValidator
{
  protected string _nullObjectError;
  protected Dictionary<ITxObject, string> _validationCache;

  public CApStopZeroCachingValidator(string nullObjectError)
  {
    this._validationCache = new Dictionary<ITxObject, string>();
    this._nullObjectError = nullObjectError;
  }

  protected override string GetValidationError(ITxObject obj)
  {
    if (obj == null)
      return this._nullObjectError;
    string cachedValidationError1 = this.GetNonCachedValidationError(obj);
    if (cachedValidationError1 != null)
      return cachedValidationError1;
    string cachedValidationError2;
    if (this._validationCache.ContainsKey(obj))
    {
      cachedValidationError2 = this._validationCache[obj];
    }
    else
    {
      cachedValidationError2 = this.GetCachedValidationError(obj);
      this._validationCache.Add(obj, cachedValidationError2);
    }
    return cachedValidationError2;
  }

  protected virtual string GetNonCachedValidationError(ITxObject obj) => (string) null;

  protected virtual string GetCachedValidationError(ITxObject obj) => (string) null;
}
